package cn.szsys.integration.billrule.strtegy.impl;

import cn.szsys.integration.billrule.entity.BillingRuleData;
import cn.szsys.integration.billrule.strtegy.AbstractDelaySaveRecord;
import cn.szsys.integration.repository.BillingDayRecordRepository;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 按日期记录收费规则
 *
 * @author rhf
 * @date 2022-12-13
 **/
@Component("dayBillRuleDelaySaveRecord")
@Slf4j
public class DayBillRuleDelaySaveRecord extends AbstractDelaySaveRecord<BillingRuleData> {

    @Resource
    private BillingDayRecordRepository billingDayRecordRepository;

    /**
     * 执行任务方法
     *
     * @param params 参数
     * @author rhf
     */
    @Override
    public void scheduleTask(List<BillingRuleData> params) {
        log.info("计费按日统计数据,操作数据条数: {}", params.size());
        if (params.isEmpty()) {
            return;
        }
        billingDayRecordRepository.batchHandler(params);
    }

    /**
     * 最大任务数
     **/
    @Override
    public int getMaxQueueCapacity() {
        return super.maxQueueCapacity;
    }

    /**
     * 单个批次任务数量
     **/
    @Override
    public int getTaskBatchSize() {
        return 20;
    }
}
